//本文件作为导航守卫，用于页面跳转
import router from "./index";
import { userUserStore } from "@/store/auth";
router.beforeEach((to)=>{
    const userStore = userUserStore();
    const isLogin = userStore.token;
    if(!isLogin){
        //未登录
        if(to.path !== "/login"){
            return {path:"/login"}
        }
    }else{
        //已登录
        if(to.path === "/login"){ //如果已登录，还是重定向到首页
            return {path:"/"}
        }
    }
})